{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python \t\t3.6\n",
      "Tensorflow \t1.0.0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Keras \t\t2.0.3\n"
     ]
    }
   ],
   "source": [
    "import sys; print('Python \\t\\t{0[0]}.{0[1]}'.format(sys.version_info))\n",
    "import tensorflow as tf; print('Tensorflow \\t{}'.format(tf.__version__))\n",
    "import keras; print('Keras \\t\\t{}'.format(keras.__version__))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline \n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "plt.style.use('ggplot')\n",
    "\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#linear regression, with additive noise\n",
    "f = lambda x, e: 2*x + 3 + e\n",
    "f_vec =  np.vectorize(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samples = 1000\n",
    "e_data = np.random.normal(0.0, 0.2, samples)\n",
    "x_data = np.random.rand(samples)\n",
    "y_data = f_vec(x_data,e_data)\n",
    "\n",
    "# transform into columns\n",
    "x_data = x_data.reshape(-1,1)\n",
    "y_data = y_data.reshape(-1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAT8AAAEyCAYAAACMONd1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHhBJREFUeJzt3WtsU+fhBvDn2HESQpw0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j06/HxcXg8\nnpTXRCIRzMzMwO12a1pOpZTUBwCGhobwpz/9CTt27DB0VzFTfW7cuIHLly+js7MTTz75JD788EO8\n9NJL+Oijj/QobkZKf958Ph+KioqwaNEiLF68GFeuXNG6qIopqdPx48fR2NgIAFi5ciXC4bBhe0+Z\neDwejI2NRb9O9TuWimHCr7a2FleuXMF///tfzM3N4eTJk/AlPGe3vr4eJ06cAHBrRrGurg6SJOlQ\n2syU1Ofjjz/G7373O+zYscPw40mZ6lNWVoZXX30Vvb296O3txYoVK7Bjxw7DzvYq+ff55je/ieHh\nYQDA9evXceXKFdx55516FFcRJXXyer04f/48AODTTz9FOBxGRUWFHsXNm8/nQ39/P4QQuHjxIsrK\nyrIawzTUDo+zZ8/ij3/8I2RZxgMPPIBHH30UgUAAtbW18Pl8CIVC6Onpwccff4zy8nJ0dHQY+ocx\nU32ef/55fPLJJ7jjjjsA3PrB3Llzp86lTi1TfWI999xz+OEPf2jY8AMy10cIgddeew2Dg4NwOBx4\n9NFHcd999+ld7LQy1enTTz/FgQMHcOPGDQDAli1b8LWvfU3nUif3m9/8Bv/6178wNTWFyspKbNq0\nCXNzcwCAhx56CEIIvPrqq/jHP/6B4uJitLW1ZfXzZqjwIyLSimG6vUREWmL4EZEtMfyIyJYYfkRk\nSww/IrIlhh8R2RLDj4hs6f8BrZAqa3aKm9UAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10e646828>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(5,5))\n",
    "plt.plot(x_data[:100], y_data[:100], 'r.')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "x_train, x_test, y_train, y_test = train_test_split(x_data, y_data, test_size=0.01, random_state=42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tensorflow as tf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Set parameters\n",
    "learning_rate = 0.01\n",
    "training_iteration = 10\n",
    "batch_size = 5\n",
    "\n",
    "FLAGS = None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# TF graph input\n",
    "x = tf.placeholder('float', [None, 1]) \n",
    "y = tf.placeholder('float', [None, 1]) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Set model weights\n",
    "w = tf.Variable(tf.zeros([1]), name='w')\n",
    "b = tf.Variable(tf.zeros([1]), name='b')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "with tf.name_scope(\"wx_b\") as scope:\n",
    "    # Construct a linear model\n",
    "    y_hat = w*x + b\n",
    "    \n",
    "    # Add summary ops to collect data\n",
    "    tf.summary.histogram(\"weights\", w)\n",
    "    tf.summary.histogram(\"biases\", b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# More name scopes will clean up graph representation\n",
    "with tf.name_scope(\"cost_function\") as scope:\n",
    "    # Minimize sum squared errors\n",
    "    cost_function = tf.reduce_sum(tf.pow(y_hat-y,2))\n",
    "    # Create a summary to monitor the cost function\n",
    "    tf.summary.scalar(\"cost_function\", cost_function)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "with tf.name_scope(\"train\") as scope:\n",
    "    # Gradient descent\n",
    "    optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost_function)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Initializing the variables\n",
    "init = tf.global_variables_initializer()\n",
    "\n",
    "# Merge all summaries into a single operator\n",
    "merged_summary_op = tf.summary.merge_all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Launch the graph\n",
    "sess = tf.InteractiveSession()\n",
    "sess.run(init)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Change this to a location on your computer\n",
    "summary_writer = tf.summary.FileWriter('./tensorboard', graph=sess.graph)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 0001 cost= 1.532150577\n",
      "Iteration: 0002 cost= 0.194283060\n",
      "Iteration: 0003 cost= 0.192620562\n",
      "Iteration: 0004 cost= 0.192455545\n",
      "Iteration: 0005 cost= 0.192430744\n",
      "Iteration: 0006 cost= 0.192425505\n",
      "Iteration: 0007 cost= 0.192424205\n",
      "Iteration: 0008 cost= 0.192423897\n",
      "Iteration: 0009 cost= 0.192423803\n",
      "Iteration: 0010 cost= 0.192423789\n"
     ]
    }
   ],
   "source": [
    "# Training cycle\n",
    "for iteration in range(training_iteration):\n",
    "    avg_cost = 0.\n",
    "    total_batch = int(samples/batch_size)\n",
    "    # Loop over all batches\n",
    "    for i in range(total_batch):\n",
    "        batch_range = slice(batch_size*i,batch_size*(i+1))\n",
    "        batch_xs = np.copy(x_train[batch_range])\n",
    "        batch_ys = np.copy(y_train[batch_range])\n",
    "        \n",
    "        # Fit training using batch data\n",
    "        sess.run(optimizer, feed_dict={x : batch_xs, y: batch_ys})\n",
    "        \n",
    "        #cost\n",
    "        cost = sess.run(cost_function, feed_dict={x: batch_xs, y: batch_ys})\n",
    "        \n",
    "        # Compute the average loss\n",
    "        avg_cost += cost/total_batch\n",
    "\n",
    "        # Write logs for each iteration\n",
    "        summary_str = sess.run(merged_summary_op, feed_dict={x: batch_xs, y: batch_ys})\n",
    "        summary_writer.add_summary(summary_str, iteration*total_batch + i)\n",
    "        \n",
    "    # Display logs per iteration step\n",
    "    print(\"Iteration: {:04d} cost= {:.9f}\".format((iteration+1),avg_cost))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test accuracy (MSE): 0.0401259\n"
     ]
    }
   ],
   "source": [
    "# Calculate accuracy\n",
    "mse = tf.reduce_mean(tf.pow(y_hat-y,2))\n",
    "print(\"Test accuracy (MSE):\", mse.eval({x: x_test, y: y_test}))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Regression a = 2.0, b = 3.0\n"
     ]
    }
   ],
   "source": [
    "w_ = w.eval()[0]\n",
    "b_ = b.eval()[0]\n",
    "print(\"Regression a = {:.2}, b = {:.2}\".format(w_, b_))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.25185341,  3.48100901],\n",
       "       [ 0.24564589,  3.46883345],\n",
       "       [ 0.69684918,  4.35383034],\n",
       "       [ 0.86998204,  4.69341564],\n",
       "       [ 0.89885168,  4.75004101],\n",
       "       [ 0.83513412,  4.62506485],\n",
       "       [ 0.90368693,  4.7595253 ],\n",
       "       [ 0.54309404,  4.05225277],\n",
       "       [ 0.20806884,  3.3951292 ],\n",
       "       [ 0.14529432,  3.27200246]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_test_predict = sess.run(y_hat, feed_dict={x:x_test})\n",
    "np.hstack([x_test[:10], y_test_predict[:10]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAT8AAAEyCAYAAACMONd1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl0VPX9//Hnzcxkn4RJBqzB0gpIrVirMvpNUJFKVIqt\nWn5KFK1WrY0EgqwhiCUiolEQLQGEr2uLoKkKpy6AGJUvWsE6AqVgZRFbkYCShayTzHZ/f8TEJGSZ\nmdzZ349zPMdk7sz9fCC88tmvoqqqihBCRJmYYBdACCGCQcJPCBGVJPyEEFFJwk8IEZUk/IQQUUnC\nTwgRlST8hBBRScJPCBGVJPyEEFFJwk8IEZX0wbx5eXm5V9ebzWYqKir8VJrAiZR6gNQlVEVKXXyp\nR0ZGhkfXSctPCBGVJPyEEFFJwk8IEZUk/IQQUUnCTwgRlST8hBBRScJPCBGVJPyEEFFJwk8IEXQG\nq5XkkhIMVmvA7hnUHR5CCGGwWknPyUFxOEg2GKgsLcVhsfj9vtLyE0IEVdz27SgOB4rLheJwELd9\ne0DuK+EnhAiq5qwsVIMBVadDNRhozsoKyH2l2yuECCqHxUJlaSlx27fTnJUVkC4vSPgJIUKAw2IJ\nWOi1km6vECIqSfgJIaKShJ8QIipJ+AkhopKEnxAiKkn4CSGikoSfECIqSfgJITQXjIMKvCWLnIUQ\nmgrWQQXekpafEEJTwTqowFsSfkIITQXroAJvSbdXCKEph8VCzYIFJGzciG3cuJDs8oKEnxBCYwar\nldSiIhSHg9iPP8Z59tkhGYDS7RVCaErG/IQQUUnG/IQQUSlYh5N6S8JPCKG5YBxO6i3p9gohopKE\nnxAiKkn4CSGikoSfECIqeTThMXnyZOLj44mJiUGn01FcXNzhdVVVef7559m1axdxcXHk5eUxePBg\nvxRYCCG04PFsb1FRESkpKV2+tmvXLo4fP86yZcs4ePAgzzzzDA8//LBmhRRCCK1p0u21Wq2MGjUK\nRVEYNmwYD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e6a73Vpb0HHniA3/72tyEZftB7XVRV5S9/+Qu7d+8mJiaG8ePHc8kllwS72Kfo\nrR5ff/01q1evpqmpCYBbb72Vn//850EuddeefPJJPvvsM+rq6khNTWXChAk4nU4ArrrqKlRV5dln\nn+Wf//wnsbGx5OXl9fnnKyTDTwgh/C3kur1CCBEIEn5CiKgk4SeEiEoSfkKIqCThJ4SIShJ+Qoio\nJOEnhIhK/x+UAV3UfJqu9AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11169c6a0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(5,5))\n",
    "plt.plot(x_data[:100], y_data[:100], 'r.')\n",
    "plt.plot(x_test, y_test_predict, 'bo')\n",
    "plt.plot([b_,w_*1+b_], 'b-')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Close the Session when we're done.\n",
    "sess.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
